%varying lamdac
clear all
clc
muc=0.033;
C=40;
 Lambdac= 2:0.1:6 ;
% Lambdac=3;

Lambdav=8;
n=ceil(((Lambdav/muc) -1)/C);
% Pv=Gaussiandist(n);
 Pv=decreasingdist(n);
Pc=Gaussiandist(n);
var_num = ((n+1)*(n+2))/2; 

b=zeros(n,1);
% Waitings=zeros(n,1);
R=zeros(length(Lambdac),1);
for j=1:length(Lambdac)
Waitings=zeros(n,1);
for i=1:n
    b(i)= Lambdac(j)*Pc(i) ;
end
cond = parameterfunspecial(n,var_num,Pv,Lambdav,b);
for i=1:n
Waitings(i)=-1/(cond(i));
end
 R(j)=max(Waitings);
% R(j)=-1/(mean(cond)+mean(b));
% R(j)=mean(Waitings(Waitings>=0));
end
% R_new=R(1
% for j=1:20
%     R_new = movavg(R_new);
%     
% end

plot(Lambdac,R)
hold on
%smoothening
% for j=1:(length(Lambdac)-1)
%     while R(j)>R(j+1) 
%     R(j)=(R(j-1)+R(j+1))/2;
%     end
% end
% for j=8:13
%     R(j)=12;
% end
% for j=72:74
%     R(j)=R(j-1)+0.0815;
% end